{extend name="admin/base_pop" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/member_list.css" />
<script type="text/javascript" src="__STATIC__/My97DatePicker/WdatePicker.js"></script>

{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt><span class="required">*</span>卖出1克金价:</dt>
		<dd>
			<input type="number" id="cur_price" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置金额</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>回收1克金价:</dt>
		<dd>
			<input type="number" id="sell_price" class="input-common">
			<p class="error">请输入数量</p>
			<p class="hint">设置金额</p>
		</dd>
	</dl>
	<dl>
		<dt><span class="required">*</span>日期:</dt>
		<dd>
			<input class="input-medium input-common harf" type="text" id="cur_time" style="width:250px;"onclick="WdatePicker()">
			<p class="error">请选择日期</p>
			<p class="hint">设置日期</p>
		</dd>
	</dl>
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="addGift();">保存</button>
		</dd>
	</dl>
</div>

<script>
	var flag = false;//防止重复提交
	//保存
	function addGift(){
		console.log("保存数据");
		var cur_price = $("#cur_price").val();
		var sell_price = $("#sell_price").val();
		var cur_time = $("#cur_time").val();

		if (cur_price == '') {
			$("#cur_price").next().show().css("display","inline-block");
			$("#cur_price").focus();
			return false;
		} else {
			$(".error").hide();
		}
		if (sell_price == '') {
			$("#sell_price").next().show().css("display","inline-block");
			$("#sell_price").focus();
			return false;
		} else {
			$(".error").hide();
		}
		if (cur_time == '') {
			$("#cur_time").next().show().css("display","inline-block");
			$("#cur_time").focus();
			return false;
		} else {
			$(".error").hide();
		}


		if(flag){
			return false;
		}
		flag = true;
		$.ajax({
			type : "post",
			url : "ADMIN_MAIN/mine/addCoinPrice",
			data : {
				'cur_price' : cur_price,
				'sell_price' : sell_price,
				'cur_time' : cur_time
			},
			async : true,
			success : function(data) {
				//alert(JSON.stringify(data));
				if (data["code"] > 0) {
					showMessage('success', data["message"]);
					setTimeout('parent.close_Layer();parent.location.reload()',2000);
				}else{
					showMessage('error', data["message"]);
				}
				flag = false;
			}
		});
	}
</script>
{/block}